package com.wj.jiangan.controller;


import com.wj.jiangan.pojo.Ordermx;
import com.wj.jiangan.service.IOrdermxService;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wj
 * @since 2019-11-05
 */
@RestController
@RequestMapping("/ordermx")
public class OrdermxController {


    @Autowired
    private IOrdermxService ordermxService;

    /**
     * 添加商品到订单详情中
     *
     * @param ordermx
     */
    @PostMapping("/")
    public Map<String, Object> addOrdermx(Ordermx ordermx) {

        int i = ordermxService.addOrdermx(ordermx);
        Map<String, Object> result = new HashMap<>();
        result.put("code", i);
        if (i != 1) {
            result.put("msg", "添加失败");
        }
        return result;
    }

    @GetMapping("delete/{xid}")
    public Map<String, Object> addOrdermx(@PathVariable Integer xid) {

        int i = ordermxService.deleteOrdermxByXid(xid);
        Map<String, Object> result = new HashMap<>();
        result.put("code", i);
        if (i != 1) {
            result.put("msg", "删除失败");
        }
        return result;
    }

}
